﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Globalization;
using System.Windows.Controls;

namespace Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Views.Converters
{
    public class DoubleToDataGridLengthConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is double)
            {
                return new DataGridLength((double)value);
            }
            else
            {
                return new DataGridLength();
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is DataGridLength)
            {
                return ((DataGridLength)value).Value;
            }
            else
            {
                return default(double);
            }
        }
    }
}
